<include file="public:header" />
<div class="allpagetop">网站设置<strong>/</strong>讨论分类</div>
<div class="admin_main_nr_dbox">
 	    <div class="pagetit">
	        <div class="ptit">讨论分类</div>
				<div class="topnav">
          <a href="{:RU('Category/cat_question',array('c_type'=>$c_type))}" <if condition="ACTION_NAME eq 'cat_question'">class="select"</if>>问题分类</a>
          <a href="{:RU('Category/cat_article',array('c_type'=>$c_type))}" <if condition="ACTION_NAME eq 'cat_article'">class="select"</if>>文章分类</a>
          <a href="{:RU('Category/cat_bbs',array('c_type'=>$c_type))}" <if condition="ACTION_NAME eq 'cat_bbs'">class="select"</if>>讨论分类</a>
				    <div class="clear"></div>
				</div>
	        <div class="clear"></div>
	    </div>
		 <form id="form1" name="form1" method="post" action="{:RU('Category/allSave')}">
   <div class="admin_list_th">
	    <div class="td1" style=" width:60%;"><div class="left_txt_td">分类名称</div></div>
		<div class="td2" style=" width:20%;">排序</div>
		<div class="td3" style=" width:20%;"><div class="admin_list_right">操作</div></div>
	  <div class="clear"></div>
	  </div>
  
  <volist name="list" id="list">
					   <div class="admin_list_tr link_bk">
						<div class="td1" style=" width:60%;">
								  <div class="category_img J_show" pid="{$list.c_id}"></div>
								  <div class="category_input"><input name="c_id[]" type="hidden" value="{$list.c_id}" />
								<input name="c_title[]" type="text"  class="input_text_default small" maxlength="100" value="{$list.c_title}"/>
								  </div>
								  
								  <div class="category_pic">
									  <if condition="$list.c_pic neq '' ">
								  		<img src="{$list.c_pic}"  border="0" title="分类图标"/>
								  		</if>
								  </div>
								  <div class="clear"></div>
						</div>
						<div class="td2" style=" width:20%;">
						<input name="c_sort[]" type="text"  class="input_text_default small" maxlength="100" value="{$list.c_sort}" style="width:50px;"/>
						</div>
						<div class="td3 edit" style=" width:20%;">
              <div class="admin_list_right link_blue">
                <a class="blue" href="{:RU('Category/cat_bbs_add',array('c_id'=>$list['c_id'],'c_type'=>$c_type))}">此类下加子类</a>
                <a href="{:RU('Category/cat_bbs_edit',array('c_id'=>$list['c_id']))}">修改</a>
                <a class="gray" href="{:RU('Category/delete',array('c_id'=>$list['c_id']))}" onclick="return confirm('删除大类会同时删除其子类，你确定要删除吗？')">删除</a>
              </div>
						</div>
					  <div class="clear"></div>
					  </div>
					  
	                   <div class="J_cat_show"></div>
  </volist>
  
  
  <div id="J_add_show_div"></div>
  
    <div class="admin_list_tr">
						<div class="td1" style=" width:60%;">
								<div class="category_list_add" id="J_category_add">添加分类</div>
						</div>
				 
					 	<div class="clear"></div>
	</div>
	<div class="admin_list_foot">
			  <div class="btnbox">
				<input name="提交" type="submit" class="admin_submit"  id="ButSave"  value="保存分类"/>
				<input type="button" class="admin_submit" id="ButADD" value="添加" onclick="window.location='{:RU('Category/cat_bbs_add',array('c_type'=>$c_type))}'"/>
			  </div>
	</div>
	</form>
 
</div>
<include file="public:footer" />
<script type="text/javascript">
$(document).ready(function(){

function get_add_html()
{
	var html='';
	html+="<div class=\"admin_list_tr link_bk\">";
	html+="<div class=\"td1\" style=\" width:60%;\">";
	html+="<div class=\"category_img\"></div>";
	html+="<div class=\"category_input\"><input name=\"add_pid[]\" type=\"hidden\" value=\"0\"/><input name=\"add_type[]\" type=\"hidden\" value=\"{$c_type}\"/>";
	html+="<input name=\"add_title[]\" type=\"text\"  class=\"input_text_default small\" />";
	html+="</div>";
	html+="<div class=\"clear\"></div>";
	html+="</div>";
	html+="<div class=\"td2\" style=\" width:20%;\">";
	html+="<input name=\"c_sort[]\" type=\"text\"  class=\"input_text_default small\" value=\"0\" style=\"width:50px;\"/>";
	html+="</div>";
	html+="<div class=\"td3\" style=\" width:20%;\">";
	html+="</div>";
	html+="<div class=\"clear\"></div>";
	html+="</div>";
	return html;
}
//添加顶级分类
$("#J_category_add").live('click',function()
{
	html=get_add_html();
	$("#J_add_show_div").before(html);
});
//打开子菜单

$(".J_show").click( function () {
	 var infobox=$(this).parent().parent().next('.J_cat_show');
      if (infobox.html()=='')//第一次加载并且显示
      {
	  	pid=$(this).attr('pid');
		get_json_content(infobox,pid);
		$(this).toggleClass('show');
      }
      else
      {
	  infobox.toggle();
	  $(this).toggleClass('show');
      }
 });
 
function get_json_content(infobox,pid)
{
	 	html="";
		$.getJSON("{:RU('Category/cat_bbs')}", { c_pid:pid}, function(data){
		  $.each(data.content, function(i, item) {
		  	html+="<div class=\"admin_list_tr link_bk\">";
			html+="<div class=\"td1\" style=\" width:60%;\">";
			html+="<div class=\"category_sub_img\">&nbsp;</div>";
			html+="<div class=\"category_input\"><input name=\"c_id[]\" type=\"hidden\"  value=\"" + item.c_id + "\"/>";
			html+="<input name=\"c_title[]\" type=\"text\"  class=\"input_text_default small\" value=\"" + item.c_title + "\"/>";
			html+="</div>";
			html+="<div class=\"clear\"></div>";
			html+="</div>";
			html+="<div class=\"td2\" style=\" width:20%;\">";
			html+="<input name=\"c_sort[]\" type=\"text\"  class=\"input_text_default small\" value=\"" + item.c_sort + "\" style=\"width:50px;\"/>";
			html+="</div>";
			html+="<div class=\"td3 edit\" style=\" width:20%;\">";
			html+="<div class=\"admin_list_right link_blue\">";
			//html+="<a href=\""+ item.addurl +"\">此类下加子类</a>";
			html+="<a href=\""+ item.editurl +"\">修改</a>";
			html+="<a class='gray' href=\""+ item.deleteurl +"\" onclick=\"return confirm('删除大类会同时删除其子类，你确定要删除吗？')\">删除</a>";
			html+="</div>";
			html+="</div>";
			html+="<div class=\"clear\"></div>";
			html+="</div>";
        });
		infobox.html(html);
		infobox.find(".category_sub_img").last().addClass('last');
		
	});
}


});
</script>
</body>
</html>